

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/fluid.png">
  <link rel="icon" href="/blog/img/avatar2.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Zhou Jie">
  <meta name="keywords" content="">
  
    <meta name="description" content="表单验证  验证项 只能作用于 :model 中的数据  验证项的 命名以及类型 需要 &#x3D;&#x3D;&#x3D; 表单v-model绑定的变量（类型默认string，整数的话 表单项需要用v-model.number来和验证项的 type&#x3D;’integer’进行比较）  触发时机：change事件要注意 一定得是 v-model值发生变化才会触发 所以 change事件 一般用于 select选项框（随便选一个值都">
<meta property="og:type" content="article">
<meta property="og:title" content="ElementuUI">
<meta property="og:url" content="https://jay213.gitee.io/blog/2024/04/07/ElementuUI/index.html">
<meta property="og:site_name" content="Zhou Jie">
<meta property="og:description" content="表单验证  验证项 只能作用于 :model 中的数据  验证项的 命名以及类型 需要 &#x3D;&#x3D;&#x3D; 表单v-model绑定的变量（类型默认string，整数的话 表单项需要用v-model.number来和验证项的 type&#x3D;’integer’进行比较）  触发时机：change事件要注意 一定得是 v-model值发生变化才会触发 所以 change事件 一般用于 select选项框（随便选一个值都">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-04-07T09:26:58.000Z">
<meta property="article:modified_time" content="2024-04-29T02:25:40.324Z">
<meta property="article:author" content="Zhou Jie">
<meta property="article:tag" content="ElementuUI">
<meta name="twitter:card" content="summary_large_image">
  
  
  
  <title>ElementuUI - Zhou Jie</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/blog/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"jay213.gitee.io","root":"/blog/","version":"1.9.4","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/blog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/blog/js/utils.js" ></script>
  <script  src="/blog/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/blog/">
      <strong>Indispensible</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/blog/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="ElementuUI"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-04-07 17:26" pubdate>
          2024年4月7日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          3.8k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          32 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">ElementuUI</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="表单"><a href="#表单" class="headerlink" title="表单"></a>表单</h1><h3 id="验证"><a href="#验证" class="headerlink" title="验证"></a><strong>验证</strong></h3><blockquote>
<ul>
<li><p>验证项 只能作用于 :model 中的数据</p>
</li>
<li><p>验证项的 <strong>命名以及类型</strong> 需要 === 表单v-model绑定的变量（类型默认string，整数的话 表单项需要用v-model.number来和验证项的 type=’integer’进行比较）</p>
</li>
<li><p>触发时机：change事件要注意 一定得是 v-model值发生变化才会触发</p>
<p>所以 change事件 一般用于 select选项框（随便选一个值都会变），而blur事件是用于input的</p>
<blockquote>
<p>change事件如果设置了不为空的验证，需要在最后按钮提交的时候，进行手动验证，才会有反应！</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-variable language_">this</span>.<span class="hljs-property">$refs</span>[formName].<span class="hljs-title function_">validate</span>(<span class="hljs-function">(<span class="hljs-params">valid</span>) =&gt;</span> &#123;<br>                <span class="hljs-keyword">if</span> (valid) &#123;<br>                    <span class="hljs-title function_">alert</span>(<span class="hljs-string">&#x27;submit!&#x27;</span>);<br>                &#125; <span class="hljs-keyword">else</span> &#123;<br>                    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#x27;error submit!!&#x27;</span>);<br>                    <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;<br>                &#125;&#125;);<br></code></pre></td></tr></table></figure></blockquote>
</li>
<li><p>有全部验证和单独验证两种</p>
<ul>
<li><p>如果把rules写在了e-form上，那么就需要针对每个都要写 验证规则</p>
</li>
<li><p>单独验证就写在 el-form-item上，例如：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">el-form-item</span> <span class="hljs-attr">prop</span>=<span class="hljs-string">&quot;和v-model一样&quot;</span> <span class="hljs-attr">:rules</span>=<span class="hljs-string">&quot;[</span></span><br><span class="hljs-string"><span class="hljs-tag">                                        &#123;...&#125;,</span></span><br><span class="hljs-string"><span class="hljs-tag">                                        &#123;...&#125;</span></span><br><span class="hljs-string"><span class="hljs-tag">                                        ]&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">el-form-item</span>&gt;</span><br></code></pre></td></tr></table></figure></li>
</ul>
</li>
</ul>
</blockquote>
<h3 id="布局"><a href="#布局" class="headerlink" title="布局"></a><strong>布局</strong></h3><blockquote>
<p>label-width和label-position这两个属性很重要。</p>
<p>label-width：标签的长度，一般设置100px</p>
<p>label-position：标签有长度，但是文字不一定有那么长，这时可以设置文字在标签容器内的位置，left|right|top</p>
</blockquote>
<h3 id="单选框"><a href="#单选框" class="headerlink" title="单选框"></a><strong>单选框</strong></h3><blockquote>
<ul>
<li>v-model绑定的值 需要是 数字类型，这样初始化才能自动选中 对应选项</li>
</ul>
</blockquote>
<h3 id="时间选择器"><a href="#时间选择器" class="headerlink" title="时间选择器"></a><strong>时间选择器</strong></h3><blockquote>
<ul>
<li><p>如何只显示 年月日，并且v-model绑定的数据也是 年月日？</p>
<p>直接加format=”yyyy-MM-dd” value-format=”yyyy-MM-dd”</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs vue">&lt;el-date-picker v-model=&quot;form.specificCycle&quot; type=&quot;date&quot; placeholder=&quot;选择日期&quot; <br>                format=&quot;yyyy-MM-dd&quot; value-format=&quot;yyyy-MM-dd&quot;&gt;<br>&lt;/el-date-picker&gt;<br></code></pre></td></tr></table></figure></li>
</ul>
</blockquote>
<h3 id="发送验证码按钮"><a href="#发送验证码按钮" class="headerlink" title="发送验证码按钮"></a><strong>发送验证码按钮</strong></h3><blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">el-button</span> <span class="hljs-attr">:disabled</span>=<span class="hljs-string">&quot;countdown &gt; 0&quot;</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">&quot;startCountdown&quot;</span>&gt;</span><br>    &#123;&#123; countdown &gt; 0 ? countdown + &#x27;秒&#x27; : &#x27;发送验证码&#x27; &#125;&#125;<br>  <span class="hljs-tag">&lt;/<span class="hljs-name">el-button</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><code class="hljs js">&lt;script&gt;<br><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;<br>  <span class="hljs-title function_">data</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-keyword">return</span> &#123;<br>      <span class="hljs-attr">countdown</span>: <span class="hljs-number">0</span>,<br>      <span class="hljs-attr">timer</span>: <span class="hljs-literal">null</span><br>    &#125;;<br>  &#125;,<br>  <span class="hljs-attr">methods</span>: &#123;<br>    <span class="hljs-title function_">startCountdown</span>(<span class="hljs-params"></span>) &#123;<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">countdown</span> = <span class="hljs-number">59</span>;<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">timer</span> = <span class="hljs-built_in">setInterval</span>(<span class="hljs-function">() =&gt;</span> &#123;<br>        <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">countdown</span> &gt; <span class="hljs-number">0</span>) &#123;<br>          <span class="hljs-variable language_">this</span>.<span class="hljs-property">countdown</span>--;<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>          <span class="hljs-built_in">clearInterval</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">timer</span>);<br>          <span class="hljs-variable language_">this</span>.<span class="hljs-property">timer</span> = <span class="hljs-literal">null</span>;<br>        &#125;<br>      &#125;, <span class="hljs-number">1000</span>);<br>    &#125;<br>  &#125;,<br>  <span class="hljs-title function_">beforeDestroy</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">timer</span>) &#123;<br>      <span class="hljs-built_in">clearInterval</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">timer</span>);<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">timer</span> = <span class="hljs-literal">null</span>;<br>    &#125;<br>  &#125;,<br>  <span class="hljs-attr">watch</span>: &#123;<br>       <span class="hljs-attr">countdown</span>: &#123;<br>           <span class="hljs-title function_">handler</span>(<span class="hljs-params">newVal</span>) &#123;<br>               <span class="hljs-variable language_">this</span>.<span class="hljs-property">countdown</span> = newVal<br>           &#125;<br>       &#125;<br>   &#125;<br>&#125;;<br>&lt;/script&gt;<br></code></pre></td></tr></table></figure>
</blockquote>
<h3 id="样式"><a href="#样式" class="headerlink" title="样式"></a>样式</h3><blockquote>
<ul>
<li><p>调整内置样式：需要加     ::v-deep</p>
<p>将el-form-item的label加粗</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs css">  ::v-deep .el-form-item__label &#123;<br>          <span class="hljs-attribute">font-weight</span>:bold<br>&gt;&#125;<br></code></pre></td></tr></table></figure></li>
</ul>
</blockquote>
<h3 id="label内容换行"><a href="#label内容换行" class="headerlink" title="label内容换行"></a><strong>label内容换行</strong></h3><blockquote>
<ul>
<li>加上 ：或 v-bind，用于允许识别特殊字符</li>
<li>双引号里面需要 加 单引号 ‘’，否则 右边就是个字符串，无法识别，再加一层单引号 才可以识别</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">el-form-item</span> <span class="hljs-attr">:label</span>=<span class="hljs-string">&quot;&#x27;内容/n(换行)&#x27;&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">el-form-item</span>&gt;</span><br></code></pre></td></tr></table></figure>
</blockquote>
<h3 id="输入框长度限制"><a href="#输入框长度限制" class="headerlink" title="输入框长度限制"></a>输入框长度限制</h3><blockquote>
<p>加上 show-word-limit、type=”text/textarea”、    maxlength=”10” 即可</p>
<ul>
<li><p>但是 在 disabled 状态下，字符限制 会消失，解决方案：</p>
<p>去掉show-word-limit，直接 用插槽的方式自己做（记住插槽使用方式）</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">el-input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text&quot;</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">&quot;form.productTags&quot;</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">&quot;请输入&quot;</span></span><br><span class="hljs-tag">                            <span class="hljs-attr">:disabled</span>=<span class="hljs-string">&quot;operator == &#x27;edit&#x27;&quot;</span> <span class="hljs-attr">maxlength</span>=<span class="hljs-string">&quot;6&quot;</span>&gt;</span><br>                            <span class="hljs-tag">&lt;<span class="hljs-name">template</span> #<span class="hljs-attr">suffix</span>&gt;</span><br>                                <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;character-count&quot;</span>&gt;</span>&#123;&#123; form.productTags.length &#125;&#125;/6<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>                            <span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span><br>                        <span class="hljs-tag">&lt;/<span class="hljs-name">el-input</span>&gt;</span><br></code></pre></td></tr></table></figure></li>
</ul>
</blockquote>
<h1 id="表格"><a href="#表格" class="headerlink" title="表格"></a>表格</h1><h3 id="属性列宽度"><a href="#属性列宽度" class="headerlink" title="属性列宽度"></a><strong>属性列宽度</strong></h3><blockquote>
<ul>
<li><p>直接在el-table-column上的width=”纯数字”加即可，改一个其他会列会自适应缩小</p>
</li>
<li><p>不要在el-table-column上来加布局，就算是行内样式也不一定能生效，因为它内置可能有优先级更高的布局，解决办法：里面重新设置一个div来设置布局</p>
</li>
<li><p><template slot-scope="scope"></template></p>
<p>一定要紧挨着el-table-column否则scope不生效</p>
</li>
<li><p>el-table-column实现可拖拽式操作</p>
<ol>
<li><p>import Sortable from “sortablejs”;—-需要用的组件内</p>
</li>
<li><p>在需要拖拽的位置添加点击方法</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">/**</span><br><span class="hljs-comment">  * <span class="hljs-doctag">@description</span>: 拖拽操作</span><br><span class="hljs-comment">  * <span class="hljs-doctag">@return</span> &#123;<span class="hljs-type">*</span>&#125;</span><br><span class="hljs-comment">  * key-&gt;el-table的class名字</span><br><span class="hljs-comment">  * tableDataForSort-&gt;要拖拽的list</span><br><span class="hljs-comment">  */</span><br> <span class="hljs-title function_">handleRow</span>(<span class="hljs-params">key</span>) &#123;<br>     <span class="hljs-keyword">let</span> tbody = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">querySelector</span>(<br>         <span class="hljs-string">`.<span class="hljs-subst">$&#123;key&#125;</span> .el-table__body-wrapper tbody`</span><br>     );<br>     <span class="hljs-keyword">if</span> (!tbody) <span class="hljs-keyword">return</span>;<br>     <span class="hljs-keyword">let</span> list = [...<span class="hljs-variable language_">this</span>.<span class="hljs-property">tableDataForSort</span>];<br>     <span class="hljs-keyword">let</span> that = <span class="hljs-variable language_">this</span>;<br>     <span class="hljs-keyword">let</span> options = &#123;<br>         <span class="hljs-attr">animation</span>: <span class="hljs-number">500</span>, <span class="hljs-comment">//动画时长</span><br>         <span class="hljs-title function_">onEnd</span>(<span class="hljs-params">&#123; newIndex, oldIndex &#125;</span>) &#123;<br>             <span class="hljs-keyword">if</span> (newIndex !== oldIndex) &#123;<br>                 <span class="hljs-keyword">const</span> currRow = list.<span class="hljs-title function_">splice</span>(oldIndex, <span class="hljs-number">1</span>)[<span class="hljs-number">0</span>];<br>                 list.<span class="hljs-title function_">splice</span>(newIndex, <span class="hljs-number">0</span>, currRow);<br>                 that.<span class="hljs-property">tableDataForSort</span> = [];<br>                 that.$nextTick(<span class="hljs-function">() =&gt;</span> &#123;<br>                     that.<span class="hljs-property">tableDataForSort</span> = list;<br>                 &#125;);<br>             &#125;<br>         &#125;,<br>     &#125;;<br>     <span class="hljs-title class_">Sortable</span>.<span class="hljs-title function_">create</span>(tbody, options);<br> &#125;<br></code></pre></td></tr></table></figure></li>
</ol>
</li>
</ul>
</blockquote>
<h1 id="布局-1"><a href="#布局-1" class="headerlink" title="布局"></a>布局</h1><p><strong>如何实现除了flex布局的justify-content以外的任意位置布局？</strong></p>
<blockquote>
<p>使用el-col 的 :span属性，一共分为了24个span，某个盒子想要占多少个span，直接在上面写上，一般配合el-row一起使用</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs html">&gt;<span class="hljs-tag">&lt;<span class="hljs-name">el-row</span>&gt;</span><br>// 各12，等于平分 <br><span class="hljs-tag">&lt;<span class="hljs-name">el-col</span> <span class="hljs-attr">:span</span>=<span class="hljs-string">&quot;12&quot;</span>&gt;</span><br>   1<br>  <span class="hljs-tag">&lt;/<span class="hljs-name">el-col</span>&gt;</span><br>   <span class="hljs-tag">&lt;<span class="hljs-name">el-col</span> <span class="hljs-attr">:span</span>=<span class="hljs-string">&quot;12&quot;</span>&gt;</span><br>   1<br>  <span class="hljs-tag">&lt;/<span class="hljs-name">el-col</span>&gt;</span><br>   <span class="hljs-tag">&lt;/<span class="hljs-name">el-row</span>&gt;</span><br></code></pre></td></tr></table></figure>

</blockquote>
<p><strong>文字的布局直接使用text-align，盒子的布局才用flex那些</strong></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/blog/categories/UI%E6%A1%86%E6%9E%B6/" class="category-chain-item">UI框架</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/blog/tags/ElementuUI/">#ElementuUI</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>ElementuUI</div>
      <div>https://jay213.gitee.io/blog/2024/04/07/ElementuUI/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Zhou Jie</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2024年4月7日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/blog/2024/04/11/React%E5%AD%A6%E4%B9%A0/" title="React学习">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">React学习</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/blog/2024/02/15/%E5%89%8D%E7%AB%AF%E9%AB%98%E9%A2%91%E9%9D%A2%E8%AF%95%E9%A2%98-%E8%BF%9B%E9%98%B6/" title="前端高频面试题(进阶)">
                        <span class="hidden-mobile">前端高频面试题(进阶)</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <div class="disqus" style="width:100%">
    <div id="disqus_thread"></div>
    
      <script type="text/javascript">
        var disqus_config = function() {
          this.page.url = 'https://jay213.gitee.io/blog/2024/04/07/ElementuUI/';
          this.page.identifier = '/blog/2024/04/07/ElementuUI/';
        };
        Fluid.utils.loadComments('#disqus_thread', function() {
          var d = document, s = d.createElement('script');
          s.src = '//' + 'fluid' + '.disqus.com/embed.js';
          s.setAttribute('data-timestamp', new Date());
          (d.head || d.body).appendChild(s);
        });
      </script>
    
    <noscript>Please enable JavaScript to view the comments</noscript>
  </div>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/events.js" ></script>
<script  src="/blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/blog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/blog/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
